package com.common.response;

/**
 * @author xin.you
 * @date 2021/4/11
 * @description
 */
public class ResponseResult {

    private Integer code;
    private String  msg;
    private Object data;


    private ResponseResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    private ResponseResult(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResponseResult() {
    }

    public static ResponseResult success(){
        return new ResponseResult(ReturnCode.SUCCESS.getCode(),ReturnCode.SUCCESS.getMsg());
    }

    public static ResponseResult success(Integer code){
        return new ResponseResult(code,ReturnCode.SUCCESS.getMsg());
    }
    public static ResponseResult success(Object data){
        return new ResponseResult(ReturnCode.SUCCESS.getCode(),ReturnCode.SUCCESS.getMsg(),data);
    }

    public static ResponseResult success(Integer code,Object data){
        return new ResponseResult(code,ReturnCode.SUCCESS.getMsg(),data);
    }
    public static ResponseResult success(Integer code, String msg, Object data){
        return new ResponseResult(code,msg,data);
    }
    public static ResponseResult success(ReturnCode returnCode){
        return new ResponseResult(returnCode.getCode(),returnCode.getMsg());
    }
    public static ResponseResult success(ReturnCode returnCode,Object data){
        return new ResponseResult(returnCode.getCode(),returnCode.getMsg(),data);
    }



    public static ResponseResult error(){
        return new ResponseResult(ReturnCode.ERROR.getCode(),ReturnCode.ERROR.getMsg());
    }
    public static ResponseResult error(Integer code){
        return new ResponseResult(code,ReturnCode.ERROR.getMsg());
    }
    public static ResponseResult error(ReturnCode errorStocke, Object data){
        return new ResponseResult(ReturnCode.ERROR.getCode(),ReturnCode.ERROR.getMsg(),data);
    }
    public static ResponseResult error(Integer code,Object data){
        return new ResponseResult(code,ReturnCode.ERROR.getMsg(),data);
    }
    public static ResponseResult error(Integer code, String msg, Object data){
        return new ResponseResult(code,msg,data);
    }
    public static ResponseResult error(ReturnCode returnCode){
        return new ResponseResult(returnCode.getCode(),returnCode.getMsg());
    }



    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
